I have defined my own popup menu in the "lib\dxl\config\formalPopupFiles" directory. |
Re: dynamically menu You also seem to be creating a menu with several items with different Labels, all activated with T, and all doing exactly the same callback. I suspect you will want a different flavor of "createItem", one that provides a dynamic Label and also provides for the execution of a specific DXL File. Perhaps this one: void createItem(int mappingFunction(),string label,char mnemonic,char accelerator, int modifierKeyFlags,IconID icon_id,string tooltip,string helptext, string inactiveHelp,string dxlFile)
|
Re: dynamically menu llandale - Wed Apr 13 15:16:53 EDT 2011
There is an enumaration attribute, which contains different types. The user (project admin) can change the number of types and the name of types. So, I must create the menu dynamically, depending on the enumeration attribute. Now, I must know, which menuItem was selected. But I don’t know any way to find out this?! It is impossible to pass a variable, neither to the callback Function, nor to a dxlFile Brigitte |
Re: dynamically menu brineu - Thu Apr 14 03:26:19 EDT 2011
OK. <1> It seems you are reading an enumerated attribute that contains enough information for you to build a menu, which I now presume is on some dialog box. <2> Your individual menu items will take the labels defined in the attribute, but all will call either the same callback or same DXLFile; and that called code needs to know which one was selected.
AttrType GetType(string NameAD)
{ AttrDef ad
AttrType at = null
string NameAT = ""
ad = find(mod, NameAD)
if (null ad)
{ return(at) // null
}
NameAT = ad.typeName
at = find(mod, NameAT)
if (null at or at.type != attrEnumeration)
at = null
return(at)
} // end GetType
int Count = at.size
int i
string Value
for (i=0; i<SizeAT; i++)
{ Value = at.strings[i] }
GoDoSomethingWithThis(Value) // Menu code in here
}
string Global[100]
int NumGlobal = 0
void DoThisOption(string Option)
{ // based on Option, do what I'm supposed to do when the menu "Option" is selected
}
void DoOption00()
{ DoThisOption(Global[0])
}
void DoOption01()
{ DoThisOption(Global[1])
}
...
void DoOption99()
{ DoThisOption(Global[99])
}
void GoDoSomethingWithThis(int NumOption, string Option)
{ whatever
if (NumOption == 0) createItem(... DoOption00, ...)
elseif(NumOption == 1) createItem(..., DoOption01, ...)
...
elseif(NumOption == 99) createItem(..., DoOption99, ...)
}
NumGlobal = at.size
int i
string Value
for (i=0; i<NumGlobal; i++)
{ if (i >=100) break // too many options
Value = at.strings[i] }
Global[i] = Value
GoDoSomethingWithThis(i, Value) // Menu code in here
}
|
Re: dynamically menu llandale - Thu Apr 14 18:01:45 EDT 2011
OK. <1> It seems you are reading an enumerated attribute that contains enough information for you to build a menu, which I now presume is on some dialog box. <2> Your individual menu items will take the labels defined in the attribute, but all will call either the same callback or same DXLFile; and that called code needs to know which one was selected.
AttrType GetType(string NameAD)
{ AttrDef ad
AttrType at = null
string NameAT = ""
ad = find(mod, NameAD)
if (null ad)
{ return(at) // null
}
NameAT = ad.typeName
at = find(mod, NameAT)
if (null at or at.type != attrEnumeration)
at = null
return(at)
} // end GetType
int Count = at.size
int i
string Value
for (i=0; i<SizeAT; i++)
{ Value = at.strings[i] }
GoDoSomethingWithThis(Value) // Menu code in here
}
string Global[100]
int NumGlobal = 0
void DoThisOption(string Option)
{ // based on Option, do what I'm supposed to do when the menu "Option" is selected
}
void DoOption00()
{ DoThisOption(Global[0])
}
void DoOption01()
{ DoThisOption(Global[1])
}
...
void DoOption99()
{ DoThisOption(Global[99])
}
void GoDoSomethingWithThis(int NumOption, string Option)
{ whatever
if (NumOption == 0) createItem(... DoOption00, ...)
elseif(NumOption == 1) createItem(..., DoOption01, ...)
...
elseif(NumOption == 99) createItem(..., DoOption99, ...)
}
NumGlobal = at.size
int i
string Value
for (i=0; i<NumGlobal; i++)
{ if (i >=100) break // too many options
Value = at.strings[i] }
Global[i] = Value
GoDoSomethingWithThis(i, Value) // Menu code in here
}
I have a procedure for every enumerated value. So, I think this way isn’t a good idea, there must give a better solution. But for a better solution I need in the callback function the label of menuItem or the int Variabel (position of menuItem). I hoped, that there is an undocumented perm. Now, I see, there is none. I have no problems with enumerated attributes or create menues, what I want is a more elegant solution. Many nevertheless thanks for your strives Brigitte |